home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ahoy 1987 January
/
Ahoy_Magazine_87-01_1987_Double_L.d64
/
Counting Combo
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
392b
|
16 lines
0 rem << cd37-8 >>
1 rem commodares problem #33-4:
2 print"[147] counting combinations"
3 rem solution by
4 rem jim speers
5 rem
10 input"enter n,r";n,r:if n<r then 10
20 n$=str$(n) : r$=str$(r)
30 if n=0 then end
40 if n=r or r=0 then t=1 : goto 70
50 if (n-r)<r then r=n-r
60 t=1 : for i=1 to r : t=t*n/i : n=n-1 : next
70 print"there are";t;"combinations of"
80 print n$;" things taken ";r$;" at a time."
90 print"" : goto 10